ioemu: support shared framebuffer and linesize != width * depth.
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 5 Mar 2008 10:54:08 +0000 (10:54 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 5 Mar 2008 10:54:08 +0000 (10:54 +0000)
When sharing the buffer between e.g. xenfb and SDL, SDL must follow
the line size.

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
tools/ioemu/cocoa.m
tools/ioemu/hw/pl110.c
tools/ioemu/hw/tcx.c
tools/ioemu/hw/vga.c
tools/ioemu/hw/xenfb.c
tools/ioemu/sdl.c
tools/ioemu/vl.c
tools/ioemu/vl.h
tools/ioemu/vnc.c

index 9551affa340259491ab630e4189ae4d3164edce2..9ba7c77a6be860a636a118ca8fdcc8e1b3f4af80 100644 (file)
@@ -96,7 +96,7 @@ static void cocoa_update(DisplayState *ds, int x, int y, int w, int h)
     cocoa_resize
  ------------------------------------------------------
 */
-static void cocoa_resize(DisplayState *ds, int w, int h)
+static void cocoa_resize(DisplayState *ds, int w, int h, int linesize)
 {
     const int device_bpp = 32;
     static void *screen_pixels;
index 16de16c0dd7e78f3f6f5202bcecd46f6d1123a05..c18fdeb62d5787d9674d156a89deaea30bc8567d 100644 (file)
@@ -262,7 +262,7 @@ static void pl110_resize(pl110_state *s, int width, int height)
 {
     if (width != s->cols || height != s->rows) {
         if (pl110_enabled(s)) {
-            dpy_resize(s->ds, width, height);
+            dpy_resize(s->ds, width, height, width * 4);
         }
     }
     s->cols = width;
@@ -375,7 +375,7 @@ static void pl110_write(void *opaque, target_phys_addr_t offset,
         s->cr = val;
         s->bpp = (val >> 1) & 7;
         if (pl110_enabled(s)) {
-            dpy_resize(s->ds, s->cols, s->rows);
+            dpy_resize(s->ds, s->cols, s->rows, s->cols * 4);
         }
         break;
     case 10: /* LCDICR */
index a1a6b68559d73730fca0c0922c889b15df250718..84ffa8b21f2695927652767137a5ca06d796d215 100644 (file)
@@ -342,7 +342,7 @@ void tcx_init(DisplayState *ds, uint32_t addr, uint8_t *vram_base,
     register_savevm("tcx", addr, 1, tcx_save, tcx_load, s);
     qemu_register_reset(tcx_reset, s);
     tcx_reset(s);
-    dpy_resize(s->ds, width, height);
+    dpy_resize(s->ds, width, height, width * 1);
 }
 
 static void tcx_screen_dump(void *opaque, const char *filename)
index ef20e2530c3d799bd85e5b5415c2018fda0a49d8..81de6c18c76c80ee2a45afc8c04f4a740da7a2d9 100644 (file)
@@ -1148,7 +1148,7 @@ static void vga_draw_text(VGAState *s, int full_update)
         cw != s->last_cw || cheight != s->last_ch) {
         s->last_scr_width = width * cw;
         s->last_scr_height = height * cheight;
-        dpy_resize(s->ds, s->last_scr_width, s->last_scr_height);
+        dpy_resize(s->ds, s->last_scr_width, s->last_scr_height, s->last_scr_width * (depth / 8));
         s->last_width = width;
         s->last_height = height;
         s->last_ch = cheight;
@@ -1571,7 +1571,7 @@ static void vga_draw_graphic(VGAState *s, int full_update)
     vga_draw_line = vga_draw_line_table[v * NB_DEPTHS + get_depth_index(s->ds)];
     if (disp_width != s->last_width ||
         height != s->last_height) {
-        dpy_resize(s->ds, disp_width, height);
+        dpy_resize(s->ds, disp_width, height, disp_width * (depth / 8));
         s->last_scr_width = disp_width;
         s->last_scr_height = height;
         s->last_width = disp_width;
@@ -2235,7 +2235,7 @@ static void vga_save_dpy_update(DisplayState *s,
 {
 }
 
-static void vga_save_dpy_resize(DisplayState *s, int w, int h)
+static void vga_save_dpy_resize(DisplayState *s, int w, int h, int linesize)
 {
     s->linesize = w * 4;
     s->data = qemu_malloc(h * s->linesize);
index 4d303c2e0a8d0970a5cac6129fb20db29c3e09dd..0d9ab14666649502f4cc6df45205ce26afad7521 100644 (file)
@@ -1183,7 +1183,7 @@ static int xenfb_register_console(struct xenfb *xenfb) {
                             xenfb_screen_dump,
                             xenfb);
        dpy_colourdepth(xenfb->ds, xenfb->depth);
-       dpy_resize(xenfb->ds, xenfb->width, xenfb->height);
+        dpy_resize(xenfb->ds, xenfb->width, xenfb->height, xenfb->row_stride);
        if (xenfb->ds->shared_buf)
            dpy_setdata(xenfb->ds, xenfb->pixels);
 
@@ -1227,7 +1227,7 @@ static void xenfb_pv_update(DisplayState *s, int x, int y, int w, int h)
     fbfront_update(fb_dev, x, y, w, h);
 }
 
-static void xenfb_pv_resize(DisplayState *s, int w, int h)
+static void xenfb_pv_resize(DisplayState *s, int w, int h, int linesize)
 {
     struct fbfront_dev *fb_dev = s->opaque;
     fprintf(stderr,"resize to %dx%d required\n", w, h);
index c3be1721226b21f92a34987593b6090de0742675..9f6f90de26195172035a7c58ded39ca32da43519 100644 (file)
@@ -90,7 +90,7 @@ static void sdl_setdata(DisplayState *ds, void *pixels)
     ds->data = pixels;
 }
 
-static void sdl_resize(DisplayState *ds, int w, int h)
+static void sdl_resize(DisplayState *ds, int w, int h, int linesize)
 {
     int flags;
 
@@ -130,7 +130,7 @@ static void sdl_resize(DisplayState *ds, int w, int h)
         ds->data = screen->pixels;
         ds->linesize = screen->pitch;
     } else {
-        ds->linesize = (ds->depth / 8) * w;
+        ds->linesize = linesize;
     }
 }
 
@@ -344,7 +344,7 @@ static void sdl_send_mouse_event(int dx, int dy, int dz, int state)
 static void toggle_full_screen(DisplayState *ds)
 {
     gui_fullscreen = !gui_fullscreen;
-    sdl_resize(ds, screen->w, screen->h);
+    sdl_resize(ds, screen->w, screen->h, ds->linesize);
     if (gui_fullscreen) {
         gui_saved_grab = gui_grab;
         sdl_grab_start();
@@ -572,7 +572,7 @@ void sdl_display_init(DisplayState *ds, int full_screen)
     ds->dpy_colourdepth = sdl_colourdepth;
     ds->dpy_setdata = sdl_setdata;
 
-    sdl_resize(ds, 640, 400);
+    sdl_resize(ds, 640, 400, 640 * 4);
     sdl_update_caption();
     SDL_EnableKeyRepeat(250, 50);
     SDL_EnableUNICODE(1);
index a5cc09ce195ae30f3cc19dc6be26097566dc1ea1..51d89faa1687d5b81454f75f084fbb485701a243 100644 (file)
@@ -4446,7 +4446,7 @@ static void dumb_update(DisplayState *ds, int x, int y, int w, int h)
 {
 }
 
-static void dumb_resize(DisplayState *ds, int w, int h)
+static void dumb_resize(DisplayState *ds, int w, int h, int linesize)
 {
 }
 
index ff2f5463c4c5b7aacf43f8eb8feb4b5b04ac56fe..3f7ff0422f43abe95245ae01191772c2c688870c 100644 (file)
@@ -941,7 +941,7 @@ struct DisplayState {
     int shared_buf;
     
     void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h);
-    void (*dpy_resize)(struct DisplayState *s, int w, int h);
+    void (*dpy_resize)(struct DisplayState *s, int w, int h, int linesize);
     void (*dpy_colourdepth)(struct DisplayState *s, int depth);
     void (*dpy_setdata)(DisplayState *s, void *pixels);
     void (*dpy_refresh)(struct DisplayState *s);
@@ -953,9 +953,9 @@ static inline void dpy_update(DisplayState *s, int x, int y, int w, int h)
     s->dpy_update(s, x, y, w, h);
 }
 
-static inline void dpy_resize(DisplayState *s, int w, int h)
+static inline void dpy_resize(DisplayState *s, int w, int h, int linesize)
 {
-    s->dpy_resize(s, w, h);
+    s->dpy_resize(s, w, h, linesize);
 }
 
 static inline void dpy_colourdepth(struct DisplayState *s, int depth)
index 2c7ee6929f64b326171cac2b7a5913883b890a68..464220dc4b119efa0fabf9fc8286af6fe807319a 100644 (file)
@@ -362,13 +362,16 @@ static void vnc_framebuffer_update(VncState *vs, int x, int y, int w, int h,
     vnc_write_s32(vs, encoding);
 }
 
-static void vnc_dpy_resize(DisplayState *ds, int w, int h)
+static void vnc_dpy_resize(DisplayState *ds, int w, int h, int linesize)
 {
     static int allocated;
     int size_changed;
     VncState *vs = ds->opaque;
     int o;
 
+    if (linesize != w * vs->depth)
+        ds->shared_buf = 0;
+
     if (!ds->shared_buf) {
         if (allocated)
             ds->data = realloc(ds->data, w * h * vs->depth);
@@ -1728,7 +1731,7 @@ static void vnc_dpy_colourdepth(DisplayState *ds, int depth)
         }
     }
 
-    vnc_dpy_resize(ds, ds->width, ds->height);
+    vnc_dpy_resize(ds, ds->width, ds->height, ds->linesize);
 }
 
 static int protocol_client_msg(VncState *vs, uint8_t *data, size_t len)